home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16648 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: hellwig.a2i!hellwig
  2. From: Oliver Hellwig <hellwig@rahul.net>
  3. Newsgroups: comp.lang.c++,comp.lang.c,comp.os.ms-windows.programmer.misc
  4. Subject: Re: fastest code
  5. Date: 11 Apr 1996 16:33:59 GMT
  6. Organization: a2i network
  7. Message-ID: <4kjc9n$f7j@samba.rahul.net>
  8. References: <316112A2.7D37@public.sta.net.cn> <4kgbmj$j3j@solutions.solon.com> <4kghs7$250@news1.mnsinc.com> <4kgu7g$n9a@solutions.solon.com>
  9. NNTP-Posting-Host: waltz.rahul.net
  10. NNTP-Posting-User: hellwig
  11.  
  12. In article <4kgu7g$n9a@solutions.solon.com>,
  13. Peter Seebach <seebs@solon.com> wrote:
  14. >In article <4kghs7$250@news1.mnsinc.com>,
  15. >Szu-Wen Huang <huang@mnsinc.com> wrote:
  16. >>Peter Seebach (seebs@solutions.solon.com) wrote:
  17. >>: In article <1996Apr10.110121.6784@friend.kastle.com>,
  18. >>: Richard Krehbiel <rich@kastle.com> wrote:
  19. >>: >Oliver Hellwig <hellwig@rahul.net> wrote:
  20. >>: >>         for (i=0; i<16; i++)
  21. >>: >>             prom[i] = prom[i+i];
  22. >
  23. >>: HUH?  the code as written has a clear effect, which is to shove all of
  24. >>: the elements of an array over one.  It certainly is an optimizer bug.
  25. >
  26. >>: Read the code carefully; the 2nd reference to prom[] uses a different
  27. >>: index into the array.  This is not a meaningless statement.
  28. >
  29. >>*You* read closely.  The second index is "i+i".  ;)  Okay, so it's a
  30. >>typo, but one who says "read carefully" is expected to.  Cheers.
  31. >
  32. >Okay, so the code becomes undefined when i becomes 8.
  33. >
  34. >And does nothing when i is 0.
  35. >
  36. >But the intervening few cases would be expected to produce
  37. >assignments.
  38. >
  39. >I still think eliminating the assignments is a bug, and that "volatile"
  40. >should not have any effect, but I'll grant that it's far
  41. >from the only problem.
  42. >
  43. >Wow.
  44. >
  45. >I can't read anymore, can I.
  46.  
  47. I'm sorry that I caused this confusion by leaving out the declaration.  
  48. It is declared as "unsigned char prom[32]".  If it were declared
  49. as "char prom[16]" it would be a broken program.  The use of the
  50. volatile keyword is irrelevant to this problem.
  51.  
  52. -- 
  53. Oliver Hellwig
  54. hellwig@rahul.net
  55.